Skip to content

Add RAK13800 Ethernet Companion targets with multi-client TCP support#2929

Closed
mathisono wants to merge 2 commits into
meshcore-dev:devfrom
mathisono:feat/rak13800-canonical-target-names
Closed

Add RAK13800 Ethernet Companion targets with multi-client TCP support#2929
mathisono wants to merge 2 commits into
meshcore-dev:devfrom
mathisono:feat/rak13800-canonical-target-names

Conversation

@mathisono

@mathisono mathisono commented Jul 12, 2026

Copy link
Copy Markdown

This PR is now rebased on top of the Ethernet support merged in #1983.

It adds the RAK13800 Ethernet Companion board-support layer and upgrades the Companion Ethernet transport from single-client behavior to multi-client framed Companion TCP.

Headline changes

Multi-client framed Companion TCP

This PR updates SerialEthernetInterface so multiple Companion TCP clients can remain connected at the same time.

The transport now supports:

  • MAX_ETH_CLIENTS, defaulting to 3
  • per-client connection slots
  • per-client receive parser state
  • round-robin receive polling
  • _last_rx tracking for command response routing
  • broadcast delivery for push frames
  • slot-only disconnect cleanup
  • rejection of only the new client when all slots are full

This avoids the old failure mode where a second connection or incoming packet could close the live Companion socket.

Framed Companion API preserved

This is still MeshCore Companion framing, not CLI/raw-line mode:

client -> radio: '<' + uint16_le(length) + payload
radio -> client: '>' + uint16_le(length) + payload

This PR intentionally does not enable raw line mode for the Companion target.

RAK13800 board-support targets

Adds canonical RAK13800 Ethernet Companion targets:

  • RAK_RAK13800_companion_radio_eth
  • RAK_RAK13800_companion_radio_eth_static_diag

Keeps compatibility aliases for older names:

  • RAK_4631_companion_radio_eth_clean
  • RAK_4631_companion_radio_eth_static_diag
  • RAK_4631_companion_radio_ethernet

Crow / gateway settings

The RAK13800 Companion target uses:

  • ETHERNET_ENABLED=1
  • ETHERNET_TCP_PORT=4403
  • FORCE_CLIENT_REPEAT=0
  • MAX_CONTACTS=128
  • framed Companion packets
  • no raw-line CLI mode

The static diagnostic target adds:

  • IP: 10.245.94.47
  • gateway: 10.245.94.33
  • DNS: 10.245.94.33
  • subnet: 255.255.255.224
  • debug logging enabled

Device model

Ethernet builds report:

RAK 4631 / RAK13800 + W5100S

Normal RAK4631 builds continue to report the normal RAK4631 model string.

What this is not

  • Not the repeater CLI target
  • Not raw-line Ethernet CLI
  • Not MQTT
  • Not Meshtastic

This is the framed MeshCore Companion API over Ethernet TCP, with multi-client support for RAK4631 + RAK13800/W5100S hardware.

Validation

Added Companion TCP smoke-test scripts for:

  • normal framed Companion TCP
  • multi-client Companion TCP behavior

Expected validation:

pio run -e RAK_RAK13800_companion_radio_eth
pio run -e RAK_RAK13800_companion_radio_eth_static_diag

python3 scripts/meshcore_companion_tcp_smoke_test.py 10.245.94.47 4403
python3 scripts/meshcore_companion_multi_client_test.py 10.245.94.47 4403

Expected static diagnostic hardware result:

  • device reachable at 10.245.94.47/27
  • TCP 4403 open
  • APP_START receives a response
  • DEVICE_QUERY receives response code 0x0d
  • two Companion TCP clients can remain connected simultaneously

@mathisono
mathisono changed the base branch from main to dev July 16, 2026 04:49
@mathisono
mathisono force-pushed the feat/rak13800-canonical-target-names branch from 11ac52f to 8cd4f64 Compare July 16, 2026 04:58
@mathisono

Copy link
Copy Markdown
Author

Rebased this PR onto dev after #1983 merged and converted it into a follow-up to the new Ethernet foundation.

What changed:

Added canonical RAK13800 board-support targets:
RAK_RAK13800_companion_radio_eth
RAK_RAK13800_companion_radio_eth_static_diag
Kept compatibility aliases for the older RAK_4631 env names.
Preserved framed MeshCore Companion TCP transport.
Updated the companion Ethernet path to support multiple simultaneous clients.
Set the Crow-compatible companion TCP port to 4403.
Added static diagnostic networking for repeatable validation at 10.245.94.47/27.
Set FORCE_CLIENT_REPEAT=0 for gateway stability.
Updated the manufacturer string for Ethernet builds to RAK 4631 / RAK13800 + W5100S.
Added Companion TCP smoke-test scripts and updated flashing/validation docs.
Important:

This is not the repeater CLI target.
This does not use raw line mode.
This is not MQTT.
It builds on the Ethernet implementation merged in #1983.

@mathisono

Copy link
Copy Markdown
Author

I want to call out the main functional change in this PR because the title may undersell it:

This is not only target-name cleanup. The PR also changes the Companion Ethernet transport from single-client behavior to multi-client framed Companion TCP.

The important behavior is:

multiple TCP clients can stay connected at the same time
new clients are accepted into open slots
existing live clients are not closed when another client connects
push frames are broadcast to connected clients
command responses route back to the client that sent the most recent command
the transport preserves MeshCore Companion framing:
client → radio: < + uint16_le length + payload
radio → client: > + uint16_le length + payload
the RAK_RAK13800 Companion targets do not enable raw-line CLI mode

This is intended to make the RAK13800 Ethernet Companion target usable by a backend such as Crow while still allowing another Companion client to remain connected.

@mathisono

Copy link
Copy Markdown
Author

Transport verification update:

I checked the key Companion Ethernet transport requirements before the final PR update.

Results:

  • server.available in src/helpers/nrf52, examples, and variants: no hits.
  • server.accept is present in SerialEthernetInterface.cpp and separately in EthernetCLI.h.
  • ETHERNET_RAW_LINE is not defined in variants/rak4631/platformio.ini.
  • FORCE_CLIENT_REPEAT is present in both examples/companion_radio/MyMesh.cpp and variants/rak4631/platformio.ini.

Target wiring check:

  • RAK_RAK13800_companion_radio_eth includes helpers/nrf52/SerialEthernetInterface.cpp.
  • RAK_RAK13800_companion_radio_eth_static_diag includes helpers/nrf52/SerialEthernetInterface.cpp.
  • Both canonical RAK13800 Companion targets include the RAKWireless/RAK13800-W5100S dependency.

So the main pass/fail requirements are passing:

  • New TCP clients are accepted with server.accept(), not server.available().
  • The Companion target preserves framed MeshCore Companion packets.
  • Raw-line CLI mode is not enabled for the Companion target.
  • The RAK13800 targets are actually wired to the Ethernet Companion transport.
  • FORCE_CLIENT_REPEAT=0 is wired for gateway stability.

@mathisono mathisono changed the title Add canonical RAK13800 Ethernet companion targets Add RAK13800 Ethernet Companion targets with multi-client TCP support Jul 16, 2026
@mathisono

Copy link
Copy Markdown
Author

Transport verification update:

I checked the key Companion Ethernet transport requirements before the final PR update.

Results:

  • server.available in src/helpers/nrf52, examples, and variants: no hits.
  • server.accept is present in SerialEthernetInterface.cpp and separately in EthernetCLI.h.
  • ETHERNET_RAW_LINE is not defined in variants/rak4631/platformio.ini.
  • FORCE_CLIENT_REPEAT is present in both examples/companion_radio/MyMesh.cpp and variants/rak4631/platformio.ini.

Target wiring check:

  • RAK_RAK13800_companion_radio_eth includes helpers/nrf52/SerialEthernetInterface.cpp.
  • RAK_RAK13800_companion_radio_eth_static_diag includes helpers/nrf52/SerialEthernetInterface.cpp.
  • Both canonical RAK13800 Companion targets include the RAKWireless/RAK13800-W5100S dependency.

So the main pass/fail requirements are passing:

  • New TCP clients are accepted with server.accept(), not server.available().
  • The Companion target preserves framed MeshCore Companion packets.
  • Raw-line CLI mode is not enabled for the Companion target.
  • The RAK13800 targets are actually wired to the Ethernet Companion transport.
  • FORCE_CLIENT_REPEAT=0 is wired for gateway stability.

@mathisono mathisono closed this Jul 16, 2026
@mathisono
mathisono deleted the feat/rak13800-canonical-target-names branch July 16, 2026 07:11
@mathisono

Copy link
Copy Markdown
Author

Superseded by #2972. The new PR uses branch \ and makes the multi-client framed Companion TCP work the headline feature.

@mathisono

Copy link
Copy Markdown
Author

Superseded by #2972. The new PR uses branch feat/rak13800-multiclient-ethernet-companion and makes the multi-client framed Companion TCP work the headline feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant